package kr.ac.mlb.action;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import kr.ac.mlb.dao.ListDao;
import kr.ac.mlb.mvc.Action;
import kr.ac.mlb.mvc.HttpUtil;
import kr.ac.mlb.vo.ContentVo;

public class WriteAction extends Action {

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		// TODO Auto-generated method stub
		String content = request.getParameter("content");
		System.out.println(content);
//		content = new String(content.getBytes("8859_1"), "UTF-8");//한글깨짐없앰
		System.out.println("content : "+content);
		String time;
		ContentVo vo = new ContentVo();
		Calendar calendar = Calendar.getInstance();
		SimpleDateFormat dataFormat = new SimpleDateFormat("yy.MM.dd HH:mm:ss");
		time = dataFormat.format(calendar.getTime());
		vo.setContent(content);		
		vo.setTime(time);
		////////StringParser 객체 생성/////////
		StringParser sp = new StringParser();
		sp.proceed();
		///////////////////////////////////
		ListDao dao = new ListDao();
		dao.insert(vo);		
		
//		HttpUtil.redirect(request, response, "/mediaLogBook/main");

	}

}
